package abstractfactory;

import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

public abstract class Factory implements FactoryIF {
	private static EntityManagerFactory emf = null;
	
	public static Factory getInstance(String database){
		if(database == null){
			return null;
		}
		else if(database.toUpperCase().equals("JPA")){
			return new FactoryJPA();
		}
		else if(database.toUpperCase().equals("DB4O")){
			return new FactoryDB4O();
		}
		else{
			return null;
		}
	}
	
	public static EntityManagerFactory getFactory() {
		if(emf == null) {
			emf = Persistence.createEntityManagerFactory("Loja2");
		}
		return emf;
	}

}